﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;

namespace NMemcached.Client.Configuration
{
    internal class ServerElementCollection : ConfigurationElementCollection
    {
        public const string HashAlgorithmKey = "hashAlgorithm";

        [ConfigurationProperty(ServerElementCollection.HashAlgorithmKey, DefaultValue = "fnv1a32", IsRequired = false)]
        [TypeConverter(typeof(HashAlgorithmConverter))]
        public HashAlgorithm HashAlgorithm
        {
            get
            {
                return (HashAlgorithm)this[ServerElementCollection.HashAlgorithmKey];
            }
        }

        public ServerElementCollection()
        {
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new ServerElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ServerElement)element).HostOrIP;
        }
    }
}